package com.danger.Model.action;

import android.text.TextUtils;

import com.danger.Model.bean.RegisterUserInfo;
import com.danger.Util.CheckMobileAndEmail;

/**
 * Created by danger on 2016/3/18.
 */
public class RegisterModelImpl implements RegisterModel {

    private String USERNAME_IS_EMPTY = "用户名为空";
    private String PASSWORD_IS_EMPTY = "密码为空";
    private String CHECK_PASSWORD_IS_EMPTY = "确认密码为空";
    private String QQ_IS_EMPTY = "QQ为空";
    private String CHECK_IS_WRONG = "前后输入的密码不一致";
    private String EMAIL_IS_WRONG = "邮箱为空";
    private String EMAIL_FORMAT_IS_WRONG = "邮箱格式不正确";
    private String INFO_IS_RIGHT = "正确";


    @Override
    public String check(RegisterUserInfo registerUserInfo) {
        if (TextUtils.isEmpty(registerUserInfo.getUsername().toString().trim())) {
            return USERNAME_IS_EMPTY;
        }
        if (TextUtils.isEmpty(registerUserInfo.getPassword().toString().trim())) {
            return PASSWORD_IS_EMPTY;
        }
        if (TextUtils.isEmpty(registerUserInfo.getCheck_password().toString().trim())) {
            return CHECK_PASSWORD_IS_EMPTY;
        }
        if (!registerUserInfo.getPassword().toString().trim().equals(registerUserInfo.getCheck_password().toString().trim())) {
            return CHECK_IS_WRONG;
        }
        if (TextUtils.isEmpty(registerUserInfo.getQq().toString().trim())) {
            return QQ_IS_EMPTY;
        }
        if (TextUtils.isEmpty(registerUserInfo.getEmail().toString().trim())) {
            return EMAIL_IS_WRONG;
        }
        if (!CheckMobileAndEmail.checkEmail(registerUserInfo.getEmail().toString().trim())) {
            return EMAIL_FORMAT_IS_WRONG;
        }
        return INFO_IS_RIGHT;
    }
}
